//
//  LCLoginViewController.m
//  JKScanTool
//
//  Created by Abner on 16/5/23.
//  Copyright © 2016年 YM. All rights reserved.
//

#import "LCLoginViewController.h"
#import "LCLeftViewController.h"
#import "MMDrawerController.h"
#import "MMDrawerVisualState.h"
#import "HomeViewController.h"
#import "UIViewController+MMDrawerController.h"

@interface LCLoginViewController ()

@property(nonatomic,strong)MMDrawerController *drawerController;

@property(nonatomic,strong)UIImageView *avatarImgV; //头像
@property(nonatomic,strong)UIButton *loginBt;
@property(nonatomic,strong)UITextField *realNameTf;
@end

@implementation LCLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = BackColor;
    
    [self creatUI];
}
-(void)viewWillAppear:(BOOL)animated{
    
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
    
}

-(void)viewWillDisappear:(BOOL)animated

{
    
    [super viewWillDisappear:animated];
    
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
    
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self.view endEditing:YES];
}
-(void)creatUI
{
    UIImageView *imgV = [[UIImageView alloc]initWithFrame:CGRectMake((ScreenWidth-77)/2, 60, 77, 77)];
    imgV.image = [UIImage imageNamed:@"avatarImg"];
    self.avatarImgV = imgV;
    [self.view addSubview:self.avatarImgV];
    
    //第一块
    UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0, 172, ScreenWidth, 44)];
    view1.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:view1];
    
    UIView *lineView0 = [[UIView alloc]init];
    lineView0.frame = CGRectMake(0, 0, ScreenWidth, 1);
    lineView0.backgroundColor = SetColorRGBValue(0xe1e1e1, 1.0);
    [view1 addSubview:lineView0];
    
    UIImageView *dlImageView1 = [[UIImageView alloc]initWithFrame:CGRectMake(10, 12, 18, 18)];
    dlImageView1.image = [UIImage imageNamed:@"denglu42_42"];
    [view1 addSubview:dlImageView1];
    
    self.realNameTf = [[UITextField alloc]initWithFrame:CGRectMake(35, 4, view1.frame.size.width-35, 34)];
    self.realNameTf.placeholder = @"请输入你的真实姓名";
    self.realNameTf.textAlignment = NSTextAlignmentLeft;
    self.realNameTf.font = [UIFont systemFontOfSize:14];
    self.realNameTf.clearButtonMode = UITextFieldViewModeWhileEditing;
    [view1 addSubview:self.realNameTf];
    
    UIView *lineView = [[UIView alloc]init];
    lineView.frame = CGRectMake(0, 43, ScreenWidth, 1);
    lineView.backgroundColor = SetColorRGBValue(0xe1e1e1, 1.0);
    [view1 addSubview:lineView];
    
    UIButton *loginBt = [UIButton buttonWithType:UIButtonTypeCustom];
    loginBt.frame = CGRectMake(15, CGRectGetMaxY(view1.frame)+25, ScreenWidth-30, 44);
    loginBt.backgroundColor = SetColorRGBValue(0xff4200, 1.0);
    loginBt.layer.masksToBounds = YES;
    loginBt.layer.cornerRadius = 8;
    [loginBt setTitle:@"登录" forState:UIControlStateNormal];
    [loginBt setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self.view addSubview:loginBt];
    self.loginBt = loginBt;
    [loginBt addTarget:self action:@selector(loginBtClicked) forControlEvents:UIControlEventTouchUpInside];
}
#pragma mark --- 登录
-(void)loginBtClicked
{
 
    if (self.realNameTf.text.length == 0) {
        [[MessShowView share] showWithMess:@"请输入你的真实姓名"];
        return;
    }else{
        NSLog(@"登录");
        [AppData share].realLoginName = self.realNameTf.text;
        LCLeftViewController *leftVC = [[LCLeftViewController alloc]init];
        HomeViewController *homeVC =[[HomeViewController alloc]init];
        self.drawerController = [[MMDrawerController alloc]initWithCenterViewController:homeVC leftDrawerViewController:leftVC];
        [self.drawerController setShowsShadow:YES];//左侧有阴影
        self.drawerController.closeDrawerGestureModeMask = MMCloseDrawerGestureModeAll;
        self.drawerController.openDrawerGestureModeMask = MMOpenDrawerGestureModeAll;
        self.drawerController.maximumLeftDrawerWidth = KleftViewW;
        
        [self.mm_drawerController setCenterViewController:homeVC withCloseAnimation:YES completion:nil];
        [self.navigationController pushViewController:self.drawerController animated:YES];
    }
   
    
}

-(void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
        self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    }
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
